<?php
/**
 * @file test001.php
 * @package taobaoke
 * @subpackage 
 * @version $id: 0.1 UTF-8 2009-7-2 下午04:39:14 $
 * @author LD King (mifunny.info)
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 * 淘宝客商品调用
 */

header("Content-Type:text/html;charset=UTF-8");
require_once '../config.inc.php';

//API系统参数
$topParamArr = array(
	'api_key' => APP_KEY,
	'method' => 'taobao.taobaoke.items.get',
	'format' => PARAM_FORMAT,
	'v' => PARAM_VERSION,
	'timestamp' => date('Y-m-d H:i:s')

);

//API用户参数
$userParamArr = array(
	'fields' => 'iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume',
	'pid' => 'mm_5410_0_0',
	'cid' => 1512,
);

$paramArr = $topParamArr + $userParamArr;

$result = Util::postResult($paramArr);
$result = Util::getXmlData($result);

//var_dump($result['taobaokeItem']);
$topItemArray = $result['taobaokeItem'];
?>
<b>此DEMO的功能：查询手机类的淘客商品</b>
<br><br>
<table border="1" width="100%">
	<tr>
		<td align="center">
			淘客商品ID
		</td>
		<td align="center">
			商品名称
		</td>
		<td align="center">
			卖家昵称
		</td>
		<td align="center">
			商品价格
		</td>
		<td align="center">
			商品图片
		</td>
		<td align="center">
			推广点击URL
		</td>
	</tr>
<?php 
for ($i = 0; $i < count($topItemArray); $i++) {
	$itemArray = $topItemArray[$i];
?>
	<tr>
		<td align="center">
			<?php echo $itemArray['iid'];?>
		</td>
		<td align="center">
			<?php echo $itemArray['title'];?>
		</td>
		<td align="center">
			<?php echo $itemArray['nick'];?>
		</td>
		<td align="center">
			<?php echo $itemArray['price'];?>
		</td>
		<td align="center">
			<a href="<?php echo $itemArray['pic_url'];?>" target="_blank">商品图片</a>
		</td>
		<td align="center">
			<a href="<?php echo $itemArray['click_url'];?>" target="_blank">推广链接</a>
		</td>
	</tr>
<?php 
}
var_dump($topItemArray);
?></table>